﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using USERS.CYT369.COM.MODELS;
using USERS.CYT369.COM.MODELS.sys;

namespace USERS.CYT369.COM.Models.Identity
{
    public class UserStore : UserStoreBase<USERS.CYT369.COM.MODELS.SysUser,
                                           int, USERS.CYT369.COM.MODELS.sys.UserClaim,
                                                USERS.CYT369.COM.MODELS.sys.UserLogin,
                                                USERS.CYT369.COM.MODELS.sys.UserToken>
    {
        public UserStore(IdentityErrorDescriber describer) : base(describer)
        {
        }

        public override IQueryable<USERS.CYT369.COM.MODELS.SysUser> Users
        {
            get
            {
                return null;
            }
        }

        public override Task AddClaimsAsync(USERS.CYT369.COM.MODELS.SysUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken = default)
        {
            return Task.CompletedTask;
        }

        public override Task AddLoginAsync(USERS.CYT369.COM.MODELS.SysUser user, UserLoginInfo login, CancellationToken cancellationToken = default)
        {
            return Task.CompletedTask;
        }

        public override Task<IdentityResult> CreateAsync(USERS.CYT369.COM.MODELS.SysUser user, CancellationToken cancellationToken = default)
        {
            throw new NotImplementedException();
        }

        public override Task<IdentityResult> DeleteAsync(USERS.CYT369.COM.MODELS.SysUser user, CancellationToken cancellationToken = default)
        {
            return Task.FromResult(IdentityResult.Success);
        }

        public override Task<USERS.CYT369.COM.MODELS.SysUser> FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken = default)
        {
            throw new NotImplementedException();
        }

        public override Task<USERS.CYT369.COM.MODELS.SysUser> FindByIdAsync(string userId, CancellationToken cancellationToken = default)
        {
            return Task.FromResult(USERS.CYT369.COM.DAL.UserService.Instance.GetUserByID(userId));
        }

        public override Task<USERS.CYT369.COM.MODELS.SysUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken = default)
        {
            return Task.FromResult(USERS.CYT369.COM.DAL.UserService.Instance.GetUserByUserName(normalizedUserName));
        }

        protected override Task<UserLogin> FindUserLoginAsync(int userId, string loginProvider, string providerKey, CancellationToken cancellationToken)
        {
            throw new NotImplementedException();
        }

        public override Task<IList<Claim>> GetClaimsAsync(USERS.CYT369.COM.MODELS.SysUser user, CancellationToken cancellationToken = default)
        {
            var list = new List<Claim>() as IList<Claim>;
            return Task.FromResult(list);
        }

        public override Task<IList<UserLoginInfo>> GetLoginsAsync(USERS.CYT369.COM.MODELS.SysUser user, CancellationToken cancellationToken = default)
        {
            throw new NotImplementedException();
        }

        public override Task<IList<USERS.CYT369.COM.MODELS.SysUser>> GetUsersForClaimAsync(Claim claim, CancellationToken cancellationToken = default)
        {
            throw new NotImplementedException();
        }

        public override Task RemoveClaimsAsync(USERS.CYT369.COM.MODELS.SysUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken = default)
        {
            return Task.CompletedTask;
        }

        public override Task RemoveLoginAsync(USERS.CYT369.COM.MODELS.SysUser user, string loginProvider, string providerKey, CancellationToken cancellationToken = default)
        {
            return Task.CompletedTask;
        }

        public override Task ReplaceClaimAsync(USERS.CYT369.COM.MODELS.SysUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken = default)
        {
            return Task.CompletedTask;
        }

        public override Task<IdentityResult> UpdateAsync(USERS.CYT369.COM.MODELS.SysUser user, CancellationToken cancellationToken = default)
        {
            throw new NotImplementedException();
        }

        protected override Task AddUserTokenAsync(USERS.CYT369.COM.MODELS.sys.UserToken token)
        {
            return Task.CompletedTask;
        }

        protected override Task<USERS.CYT369.COM.MODELS.sys.UserToken> FindTokenAsync(USERS.CYT369.COM.MODELS.SysUser user, string loginProvider, string name, CancellationToken cancellationToken)
        {
            throw new NotImplementedException();
        }

        protected override Task<USERS.CYT369.COM.MODELS.SysUser> FindUserAsync(int userId, CancellationToken cancellationToken)
        {
            throw new NotImplementedException();
        }


        public override Task<SysUser> FindByLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken = default)
        {
            return base.FindByLoginAsync(loginProvider, providerKey, cancellationToken);
        }

        protected override Task<USERS.CYT369.COM.MODELS.sys.UserLogin> FindUserLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken)
        {
            throw new NotImplementedException();
        }

        protected override Task RemoveUserTokenAsync(USERS.CYT369.COM.MODELS.sys.UserToken token)
        {
            return Task.CompletedTask;
        }
    }
}
